package com.v5.mr.reveredindex;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

/**
 * 倒排索引
 *
 */
public class RevertedIndexMain {

	public static void main(String[] args) throws Exception {
		Job job = Job.getInstance(new Configuration());
		job.setJarByClass(RevertedIndexMain.class);
	
		//设置Mapper
		job.setMapperClass(RevertedIndexMapper.class);
		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(Text.class);
		
		//设置Combiner
		job.setCombinerClass(RevertedIndexCombiner.class);
		
		//设置Reducer
		job.setReducerClass(RevertedIndexReducer.class);
		job.setOutputKeyClass(Text.class);		
		job.setOutputValueClass(Text.class);
		
		//设置输入和输出
		FileInputFormat.setInputPaths(job, new Path(args[0]));
		FileOutputFormat.setOutputPath(job, new Path(args[1]));
		
		//执行
		job.waitForCompletion(true);

	}
}







